package org.bootlimn.common;

/**
 * @author satya
 * This class defines the structure of a perpro element as outputed by perproinfo and functions
 * to access the individual attributes
 *
 */

	public class Perpro {

		private int time;				// timestamp
		private int pid;				// process id
		private String execname;		// name of process name
	    private String probefunc;		// name of the function that was probed
	    private int utime;				// user time
	    private int stime;				// system time
			
	    /**
		 * constructor
		 * @param	time				for timestamping
		 * @param	pid					for process id
		 * @param	ppid				for parent process id
		 * @return
		 * @throws IOException            if an I/O error occurs
		 */
		public Perpro(int time, int pid, String execname, String probefunc, int utime, int stime) {
			this.time = time;
			this.pid = pid;
			this.execname = execname;
	        this.probefunc = probefunc;
	        this.utime = utime;
	        this.stime = stime;
	        
		}
		
		public Perpro()
		{
			this.time = 0;
			this.pid = 0;
			this.execname = "";
	        this.probefunc = "";
	        this.utime = 0;
	        this.stime = 0;
		}

		//functions to access individual attributes

		public int getTime() {
			return time;
		}

		public void setTime(int time) {
			this.time = time;
		}

		public int getPid() {
			return pid;
		}
	       
	        public void setPid(int pid) {
			this.pid = pid;
		}

		public String getExecname() {
			return execname;
		}

		public void setExecname(String execname) {
			this.execname = execname;
		}

	        public String getProbefunc() {
			return probefunc;
		}

		public void setProbefunc(String probefunc) {
			this.probefunc = probefunc;
		}
		
		public int getUtime() {
			return utime;
		}
	       
	    public void setUtime(int utime) {
			this.utime = utime;
		}
	    
		public int getStime() {
			return stime;
		}
		       
		public void setStime(int stime) {
			this.stime = stime;
		}
		// To print it all out (temporary for text output purpose)
		
		public String toString() {
			StringBuffer sb = new StringBuffer();
			sb.append("Per Process CPU Details - ");
			sb.append("Time" + getTime());
			sb.append(",");
			sb.append("Pid" + getPid());
			sb.append(",");
			sb.append("Execname:" + getExecname());
			sb.append(",");
			sb.append("Probefunc:" + getProbefunc());
			sb.append(",");
			sb.append("Probefunc:" + getProbefunc());
			sb.append(",");
			sb.append("Utime" + getUtime());
			sb.append(",");
			sb.append("Stime" + getStime());
			sb.append(".\n");
			
			return sb.toString();
		}

}
